from PySide6 import QtWidgets
from PySide6.QtWidgets import QWidget
from PySide6.QtCharts import QChart, QChartView, QLineSeries, QValueAxis
from PySide6.QtCore import Qt

class Demo(QWidget):
    """Line Chart Demo Class."""
    def __init__(self, parent=None):
        super().__init__(parent)
        
        # Create chart
        self.chart = QChart()
        self.chart.setTitle("Line Chart Example")
        
        # Create line series
        series = QLineSeries()
        series.setName("Line 1")
        
        # Add data points
        series.append(0, 6)
        series.append(2, 4)
        series.append(3, 8)
        series.append(7, 4)
        series.append(10, 5)
        
        self.chart.addSeries(series)
        
        # Create axes
        axisX = QValueAxis()
        axisX.setRange(0, 10)
        axisX.setLabelFormat("%d")
        axisX.setTitleText("X Axis")
        
        axisY = QValueAxis()
        axisY.setRange(0, 10)
        axisY.setLabelFormat("%d")
        axisY.setTitleText("Y Axis")
        
        self.chart.addAxis(axisX, Qt.AlignBottom)
        self.chart.addAxis(axisY, Qt.AlignLeft)
        
        series.attachAxis(axisX)
        series.attachAxis(axisY)
        
        # Create chart view
        chart_view = QChartView(self.chart)
        self.layout = QtWidgets.QVBoxLayout()
        self.layout.addWidget(chart_view)
        self.setLayout(self.layout)

def runDemo(parent):
    widget = Demo(parent)
    return widget